/*
 * Copyright (c) 2021.版权所有高金磊
 */

package 领扣算法.A简单题.删除某些元素后的数组均值;

import java.util.Arrays;
import java.util.LinkedList;

public class Main {
    public double trimMean(int[] arr) {
        Arrays.sort(arr);
        int remove= (int) (arr.length*0.05);
        LinkedList<Integer> data=new LinkedList<>();
        for (int i : arr) {
            data.addLast(i);
        }
        for (int i = 0; i < remove; i++) {
            data.pollFirst();
            data.pollLast();
        }
        double res=0;
        for (Integer datum : data) {
            res+=datum;
        }
        return res/data.size();
    }
}
